#!/usr/bin/python3

#pip3 install xlrd==1.2.0
import xlrd

print("Hello, World!")

#打开excel
wb = xlrd.open_workbook('language_entry_table.xlsx')

#按工作簿定位工作表
table = wb.sheet_by_name('index')

#print(sh.nrows)#有效数据行数
#print(sh.ncols)#有效数据列数
#print(sh.cell(0,0).value)#输出第一行第一列的值
#print(sh.row_values(0))#输出第一行的所有值
#将数据和标题组合成字典
#print(dict(zip(sh.row_values(0),sh.row_values(1))))

#遍历excel，打印所有数据
for i in range(table.nrows):
    print(table.row_values(i))

file = open("language_entry_table.txt", "wb")

for i in range(1,table.nrows):
    file.write(bytes("LANGUAGE_ENTRY(",'utf8'))
    file.write(bytes(str(table.cell(i,1).value) ,'utf8'))
    file.write(bytes(",    \"" + str(table.cell(i,2).value) + "\"",'utf8'))
    file.write(bytes(",    \"" + str(table.cell(i,3).value) + "\"",'utf8'))
    file.write(bytes(",    \"" + str(table.cell(i,4).value) + "\"",'utf8'))
    file.write(bytes(")\n",'utf8'))
    
file.close()
